package com.itheima.supplier.controller;

import com.itheima.cache.CacheService;
import com.itheima.recharge.constants.SupplierConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * Created by 传智播客*黑马程序员.
 */
@RestController
@Slf4j
public class RechargeNotifyController {

    @Autowired
    private CacheService cacheService;

    @RequestMapping("/recovery")
    public String recovery(String supply){
        Set<String> excluedes = cacheService.setMembers(SupplierConstants.exclude_supplier);
        if(excluedes.contains(supply)){
            cacheService.sRemove(SupplierConstants.exclude_supplier,supply);
            return "恢复成功!";
        }else {
            return "供应商编号不存在!";
        }
    }
}
